/*********************\
* Author:Dzlua
* QQ:505544956
* Time:2017/04/15
\**********************/
#include "LuaDateTime.h"

#define CObjPtr ((CDateTimeUI*)m_cobj)

namespace DuiLib {

int LuaDateTime::GetTime(LuaState *L)
{
    SYSTEMTIME t = CObjPtr->GetTime();
    LuaHelperNS::PushSysTime(L, t);
    return 1;
}

int LuaDateTime::SetTime(LuaState *L)
{
    LuaStack args(L);
    SYSTEMTIME t = LuaHelperNS::GetSysTime(args[2]);
    CObjPtr->SetTime(&t);
    return 0;
}

void LuaDateTime::SetReadOnly(bool bReadOnly)
{
    CObjPtr->SetReadOnly(bReadOnly);
}

bool LuaDateTime::IsReadOnly()
{
    return CObjPtr->IsReadOnly();
}

void LuaDateTime::UpdateText()
{
    CObjPtr->UpdateText();
}

SDLUA_BEGIN_REGISTER(LuaDateTime, DateTime, Label)
    SDLUA_REGISTER_FUN_LUA(LuaDateTime, GetTime, GetTime)
    SDLUA_REGISTER_FUN_LUA(LuaDateTime, SetTime, SetTime)

    SDLUA_REGISTER_FUN_CPP(LuaDateTime, SetReadOnly, SetReadOnly)
    SDLUA_REGISTER_FUN_CPP(LuaDateTime, IsReadOnly, IsReadOnly)

    SDLUA_REGISTER_FUN_CPP(LuaDateTime, UpdateText, UpdateText)
    
SDLUA_END_REGISTER

SDLUA_BEGIN_UNREGISTER(LuaDateTime, DateTime)
SDLUA_END_UNREGISTER(DateTime)

}

#undef CObjPtr